/*
=======================================================================

  BOTS Soldier Commands menu

=======================================================================
*/
#include "ui_local.h"
#include "ui_BOTS.h"

#define BOTS_SOLDIER_CONQUER		130
#define BOTS_SOLDIER_SPLIT			131
#define BOTS_SOLDIER_GUIDE			132
#define BOTS_SOLDIER_TAG			133

typedef struct 
{
  menuframework_s menu;  

  menutext_s	title;
  menutext_s	conquer;
  menutext_s	split;
  menutext_s	tag;
  menutext_s	guide;
  menutext_s	cancel;
} soldierCommands_t;

static soldierCommands_t		s_soldier;

/*
=================
BOTS_SoldierCommandsMenu_Event
callback routine
=================
*/
void BOTS_SoldierCommandsMenu_Event( void *ptr, int notification ) 
{
	if( notification != QM_ACTIVATED )
		return;

	// any event will kill the menu
	UI_PopMenu();

	switch( ((menucommon_s*)ptr)->id ) 
	{
	case BOTS_CANCEL:
		break;
	case BOTS_SOLDIER_CONQUER:
		trap_Cmd_ExecuteText( EXEC_APPEND, "conquer\n" );
		break;
	case BOTS_SOLDIER_SPLIT:
		trap_Cmd_ExecuteText( EXEC_APPEND, "split\n" );
		break;
	case BOTS_SOLDIER_GUIDE:
		trap_Cmd_ExecuteText( EXEC_APPEND, "guide\n" );
		break;
	case BOTS_SOLDIER_TAG:
		trap_Cmd_ExecuteText( EXEC_APPEND, "tag\n" );
		break;

	// oops - not a valid choice
	default:
		Com_Printf("%i is not a valid choice\n", ((menucommon_s*)ptr)->id);
		break;
	}
}

/*
=================
BOTS_SoldierCommandsMenu_Init
=================
*/
void BOTS_SoldierCommandsMenu_Init() 
{
	int y;

	memset( &s_soldier, 0 ,sizeof(soldierCommands_t) );
	s_soldier.menu.wrapAround = qtrue;
	s_soldier.menu.fullscreen = qfalse;

	y = 96;
	s_soldier.title.generic.type	= MTYPE_PTEXT;
	s_soldier.title.generic.flags	= QMF_CENTER_JUSTIFY;
	s_soldier.title.generic.x		= 320;
	s_soldier.title.generic.y		= y;
	s_soldier.title.string			= "SOLDIER COMMANDS MENU";
	s_soldier.title.color			= color_bots_menu;
	s_soldier.title.style			= UI_CENTER|UI_SMALLFONT;

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_soldier.conquer.generic.type		= MTYPE_PTEXT;
	s_soldier.conquer.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_soldier.conquer.generic.x			= 320;
	s_soldier.conquer.generic.y			= y;
	s_soldier.conquer.generic.id		= BOTS_SOLDIER_CONQUER;
	s_soldier.conquer.generic.callback	= BOTS_SoldierCommandsMenu_Event; 
	s_soldier.conquer.string			= "CONQUER MODE - conquer";
	s_soldier.conquer.color				= color_bots_menu;
	s_soldier.conquer.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 1) {
		s_soldier.conquer.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_soldier.split.generic.type		= MTYPE_PTEXT;
	s_soldier.split.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_soldier.split.generic.x			= 320;
	s_soldier.split.generic.y			= y;
	s_soldier.split.generic.id			= BOTS_SOLDIER_SPLIT;
	s_soldier.split.generic.callback	= BOTS_SoldierCommandsMenu_Event; 
	s_soldier.split.string				= "SPLIT ROCKETS - split";
	s_soldier.split.color				= color_bots_menu;
	s_soldier.split.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 3) {
		s_soldier.split.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_soldier.tag.generic.type		= MTYPE_PTEXT;
	s_soldier.tag.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_soldier.tag.generic.x			= 320;
	s_soldier.tag.generic.y			= y;
	s_soldier.tag.generic.id		= BOTS_SOLDIER_TAG;
	s_soldier.tag.generic.callback	= BOTS_SoldierCommandsMenu_Event; 
	s_soldier.tag.string			= "TAG CANNON - tag";
	s_soldier.tag.color				= color_bots_menu;
	s_soldier.tag.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 2) {
		s_soldier.tag.generic.flags |= QMF_GRAYED;
	}

	y += BOTS_VERTICAL_SPACING;
	s_soldier.guide.generic.type		= MTYPE_PTEXT;
	s_soldier.guide.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_soldier.guide.generic.x			= 320;
	s_soldier.guide.generic.y			= y;
	s_soldier.guide.generic.id			= BOTS_SOLDIER_GUIDE;
	s_soldier.guide.generic.callback	= BOTS_SoldierCommandsMenu_Event; 
	s_soldier.guide.string				= "GUIDED ROCKETS - guide";
	s_soldier.guide.color				= color_bots_menu;
	s_soldier.guide.style				= UI_CENTER|UI_SMALLFONT;

	if (BOTS_GetClassLevel() < 4) {
		s_soldier.guide.generic.flags |= QMF_GRAYED;
	}

	// skip a space
	y += BOTS_VERTICAL_SPACING;

	y += BOTS_VERTICAL_SPACING;
	s_soldier.cancel.generic.type		= MTYPE_PTEXT;
	s_soldier.cancel.generic.flags		= QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
	s_soldier.cancel.generic.x			= 320;
	s_soldier.cancel.generic.y			= y;
	s_soldier.cancel.generic.id			= BOTS_CANCEL;
	s_soldier.cancel.generic.callback	= BOTS_SoldierCommandsMenu_Event; 
	s_soldier.cancel.string				= "CANCEL";
	s_soldier.cancel.color				= color_bots_menu;
	s_soldier.cancel.style				= UI_CENTER|UI_SMALLFONT;

	Menu_AddItem( &s_soldier.menu, &s_soldier.title );
	Menu_AddItem( &s_soldier.menu, &s_soldier.conquer );
	Menu_AddItem( &s_soldier.menu, &s_soldier.split );
	Menu_AddItem( &s_soldier.menu, &s_soldier.tag );
	Menu_AddItem( &s_soldier.menu, &s_soldier.guide );
	Menu_AddItem( &s_soldier.menu, &s_soldier.cancel );
}

void BOTS_SoldierCommandsMenu_f( void ) 
{
	// force as top level menu
	uis.menusp = 0;  

	// set menu cursor to a nice location
	uis.cursorx = 319;
	uis.cursory = 80;

	// setup the menu structure
	BOTS_SoldierCommandsMenu_Init();

	// show the menus
	UI_PushMenu( &s_soldier.menu );
}
